package com.game.pool {
	import com.game.units.Tower;
	public class TowerPool {
		private var unusedList:Vector.<Tower>;
		private var _limit:int = 0;
		public function TowerPool(limit:int = 200) {
			_limit = limit;
			unusedList = new Vector.<Tower>(_limit);
			for (var i:int = 0; i < _limit; i++) {
				unusedList[i] = new Tower();
			}
		}
		public function getObject():Tower {
			if (unusedList.length <= 0) {
				return null;
			}
			return unusedList.pop();
		}
		public function returnObject(obj:Tower):void {
			if (obj == null || unusedList.length == _limit) {
				return;
			}
			unusedList.push(obj);
		}
	}
}